package com.faxsun.core.persist.dao;

import java.util.Date;
import java.util.List;

import mtons.modules.persist.Dao;
import mtons.modules.pojos.Page;

import com.faxsun.core.persist.entity.LivePO;

public interface LiveDao extends Dao<LivePO> {
    
    /**
     * List all existing live events
     */
    public List<LivePO> listAllEvent(Page page, boolean isAdminEnd);

    /**
     * List recent live event regarding to current time, including both events 
     * whose startTime is 2months/60days ahead of current time and events 
     * whose startTime is 2months/60days after of current time
     * 
     * @param current time as base
     * @return list of recent events
     */
	public List<LivePO> listRecent(Page page, Date current);
	
    /**
     * List finished live event regarding to current time, including events 
     * whose endTime is ahead of current time
     * 
     * @param current time as base
     * @return list of finished events
     */
    public List<LivePO> listFinished(Page page, Date current);
    
    /**
     * List active live event regarding to current time, including events 
     * where current time could fit in their range: [startTime,endTime]
     * 
     * @param current time as base
     * @return list of active events
     */
    public List<LivePO> listActive(Page page, Date current);
    
    /**
     * List live event regarding to given topic
     * 
     * @param topic 
     * @return live event with given topic or null
     */
    public LivePO findByTopic(String topic);
    
    /**
     * List live event whose start time is after current time
     * @param page
     * @param current
     * @return
     */
    public List<LivePO> listFuture(Page page,Date current);
    
    /**
     * The same as {@link #listActive(Page, Date)} but order by startTime asc
     * @param page
     * @param current
     * @return
     */
    public List<LivePO> listPresent(Page page, Date current);
    
    /**
     * The same as {@link #listFinished(Page, Date)} but order by startTime asc
     * @param page
     * @param current
     * @return
     */
    public List<LivePO> listPast(Page page, Date current);
    
    /**
     * 统计以topic为开头的频道数目
     * @param topic
     * @return
     */
    public int countBySimlarTopic(String topic);
    
    /**
     * 统计所有频道数
     * @return
     */
    public int countAllLive();

}
